package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.News;
import com.example.demo.service.NewsService;
import com.example.demo.spider.News81Processor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {
    @Autowired
    private News81Processor processor;

    @Autowired
    private NewsService service;

    @GetMapping("/")
    public Page<News> index() {
        return service.page(new Page<News>());
    }

    @GetMapping("spider")
    public String spider() {
        processor.start();
        return "hello world!";
    }
}
